package com.yeren.file.file;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class FileReadWrite {
	
	
	public static void main(String[] args) {
		File f = new File("E:\\abc.ppt");
		writeFile(f);
		readFile(f);
	}

	public static void writeFile(File file){
		try {
			OutputStream os = new FileOutputStream(file);
			String s = "I am java";
			os.write(s.getBytes());
			os.flush();
			os.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void readFile(File file){
		try {
			InputStream os = new FileInputStream(file);
			String str = "";
			int temp =-1;
			while ((temp= os.read()) != -1) {
				str += (char)temp;
			}
			System.out.println(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
